//
//  PersonCenterViewController.m
//  WULIHH
//
//  Created by tang on 16/4/27.
//  Copyright © 2016年 tang. All rights reserved.
//

#import "PersonCenterViewController.h"
#import "Header.h"
#import "headerView.h"
#import "WuLiUserWorkReauest.h"
#import "WuLiRequestFlowStar.h"

#import "UserInfoModel.h"

#import "PersonViewController.h"
#import "SetupViewController.h"
#import "ShowDetalImageViewController.h"
#import "SystemNotionViewController.h"




#import "FavWorkCollectionView.h"
#import "MyWorkTableView.h"
#import "MeassageView.h"

@interface PersonCenterViewController ()<headerViewDelegate, MyWorkTableViewDelegate, FavWorkCollectionViewDelegate, ButtonDelegate>
{
    int bt1;
    int bt2;
    int bt3;
    
    FavWorkCollectionView *favCollectionVew;
    MyWorkTableView *myWorkTableView;
    MeassageView *messageView;
    headerView *header;
    
    NSMutableArray *myWorkArray;
    NSMutableArray *favMutableArray;
    
}

@end

@implementation PersonCenterViewController



- (void)loadView
{
    [super loadView];
    bt1 = 1;
    bt2 = 0;
    bt3 = 0;
    
    favCollectionVew = [[FavWorkCollectionView alloc] initWithFrame:CGRectMake(0, 165, WithView, heightView-43-176 )];
    [self.view addSubview:favCollectionVew];
    
    myWorkArray = [NSMutableArray new];
    favMutableArray = [NSMutableArray new];
    
    myWorkTableView = [[MyWorkTableView alloc] initWithFrame:CGRectMake(0, 184, WithView, heightView-184-49)];
    [self.view addSubview:myWorkTableView];
    // 消息
    messageView = [[MeassageView alloc] initWithFrame:CGRectMake(0, 184, WithView, heightView - 184)];
    [self.view addSubview:messageView];
    [favCollectionVew beginRefresh];
    
//    [WuLiUserWorkReauest requestUserWorkCollect:[UserInfoModel userIDString]];
    
}



- (void)viewDidLoad {
    [super viewDidLoad];
    self.navigationController.navigationBarHidden = YES;
    header = [[headerView alloc] initWithFrame:CGRectMake(0, 0, WithView, 184)];
    [self.view addSubview:header];
    [header setMheaderViewDelegate:self];
    [header loadUserInfo];
    
    [myWorkTableView setMMyWorkTableViewDelegate:self];
    [favCollectionVew setMFavWorkCollectionViewDelegate:self];
    
    [favCollectionVew setHidden:NO];
    [myWorkTableView setHidden:YES];
    [messageView setHidden:YES];
    [messageView setDelegate:self];
    
    
    
}


- (void)viewWillAppear:(BOOL)animated
{
    [super viewWillAppear:animated];
    [self.tabBarController setHidesBottomBarWhenPushed:NO];
    [[UIApplication sharedApplication] setStatusBarHidden:NO];
}



- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}


#pragma mark---切换视图
- (void)buttonWithTag:(NSInteger)tag
{
    if (tag == 1)
    {
        [favCollectionVew setHidden:NO];
        [myWorkTableView setHidden:YES];
        [messageView setHidden:YES];
    }
    else if (tag == 2)
    {
        [favCollectionVew setHidden:YES];
        [myWorkTableView setHidden:NO];
        [messageView setHidden:YES];
        if (bt2 == 0)
        {
            //刷新
            bt2 = 1;
            [myWorkTableView beginRefresh];
        }
        else
        {
            //不刷新
        }
    }
    else if (tag == 3)
    {
        [favCollectionVew setHidden:YES];
        [myWorkTableView setHidden:YES];
        [messageView setHidden:NO];
        
    }
}





#pragma mark---进入zuopi
- (void)pushWorkDetal:(NSString *)IDString withDic:(NSDictionary *)dic
{
//    NSLog(@"%@", [myWorkArray objectAtIndex:[IDString intValue]]);
    NSLog(@"%@", myWorkArray);
    ShowDetalImageViewController *detalView = [[ShowDetalImageViewController alloc] init];
    detalView.IDString = [dic valueForKey:@"id"];
    detalView.textStr = [dic valueForKey:@"title"];
    [self.navigationController pushViewController:detalView animated:YES];
}


- (void)pushWithWork:(NSString *)idString withInfo:(NSDictionary *)dic
{
//    NSLog(@"----------%@", idString);
    ShowDetalImageViewController *detalView = [[ShowDetalImageViewController alloc] init];
    detalView.IDString = [dic valueForKey:@"id"];
    detalView.textStr = [dic valueForKey:@"title"];
    [self.navigationController pushViewController:detalView animated:YES];

}
#pragma mark-----
- (void)pushCenter
{
    PersonViewController *personView = [[PersonViewController alloc] init];
    [self.navigationController pushViewController:personView animated:YES];
}


- (void)pushSetting
{
    SetupViewController *settingView = [[SetupViewController alloc] init];
    [self.navigationController pushViewController:settingView animated:YES];
}



- (void)MesssageTouch:(NSInteger)number
{
    if (number == 100)
    {
        SystemNotionViewController *systemVC = [[SystemNotionViewController alloc] init];
        [self.navigationController pushViewController:systemVC animated:YES];
    }
}

/*
 #pragma mark - Navigation
 
 // In a storyboard-based application, you will often want to do a little preparation before navigation
 - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
 // Get the new view controller using [segue destinationViewController].
 // Pass the selected object to the new view controller.
 }
 */

@end
